<?php
/**
 * GPA Description
 * @package 
 * @name images
 * @filesource images.php
 * @author Meta Sanjaya
 */

$images = $db->query("SELECT a.*, b.description FROM #_gallery_images a LEFT JOIN #_gallery_images_description b ON b.image_id = a.image_id WHERE published='1' ORDER BY time_stamp DESC")->rows;

for($i=0, $j=count($images); $i<$j; $i++) {
    $imagepath = PAGE_PATH . "images/fullscreen/" . $images[$i]['file'];
    $thumbpath = PAGE_PATH . "images/thumbnails/";
    $info = getimagesize($imagepath);
    
    if($info[1] > $info[0]) {
        $nwidth = 0;
        $nheight = $CONFIG['img_thumb_size'];
    } else {
        $nwidth = $CONFIG['img_thumb_size'];
        $nheight = 0;
    }

    $thumurl = create_thumbnail($imagepath, $nwidth, $nheight, $thumbpath, PAGE_PATH);
    $images[$i]['thumb'] = PAGE_URL . $thumurl;
    $images[$i]['url'] = HTTP_SERVER . "?page=gallery&act=view&iid=" . $images[$i]['image_id'];
}

include_once 'index.xml.php';